package com.ourcraft.informationcollectionsystem.utils;

import java.lang.reflect.Field;
import java.util.HashMap;

public class ColumnNameCN {
    public static HashMap<String, String> map_company_column = new HashMap<>();
    public static HashMap<String, String> map_inv_column = new HashMap<>();
    public static HashMap<String, String> map_form_column = new HashMap<>();
    public static HashMap<String, String> map_table = new HashMap<>();

    static {
        map_company_column.put("company_id", "公司ID");
        map_company_column.put("user_id", "用户ID");
        map_company_column.put("company_city", "所在城市");
        map_company_column.put("company_location", "位置");
        map_company_column.put("company_inst_code", "组织机构代码");
        map_company_column.put("company_chinese_name", "中文名");
        map_company_column.put("company_english_name", "英文名");
        map_company_column.put("company_nature", "性质");
        map_company_column.put("company_industry", "行业");
        map_company_column.put("company_business", "业务");
        map_company_column.put("company_contacts", "联系人");
        map_company_column.put("company_address", "地址");
        map_company_column.put("company_postcode", "邮政编码");
        map_company_column.put("company_phone", "电话");
        map_company_column.put("company_fax", "传真");
        map_company_column.put("company_email", "电子邮箱");
    }

    static {
        map_inv_column.put("pattern_id", "调查期模式ID");
        map_inv_column.put("investigation_id", "调查期ID");
        map_inv_column.put("investigation_title", "标题");
        map_inv_column.put("investigation_start_date", "开始日期");
        map_inv_column.put("investigation_length", "长度（天）");
        map_inv_column.put("investigation_description", "描述");
    }

    static {
        map_form_column.put("form_id", "表单ID");
        map_form_column.put("company_id", "公司ID");
        map_form_column.put("investigation_id", "调查期ID");
        map_form_column.put("form_start_total_num", "建档期就业人数");
        map_form_column.put("form_end_total_num", "当前调查期就业人数");
        map_form_column.put("form_decrease_type", "人数减少原因类型");
        map_form_column.put("form_first_reason", "第一原因");
        map_form_column.put("form_second_reason", "第二原因");
        map_form_column.put("form_third_reason", "第三原因");
        map_form_column.put("form_reason_description", "原因描述");
    }

    static {
        map_table.put("com.ourcraft.informationcollectionsystem.entity.Company", "公司备案数据");
        map_table.put("com.ourcraft.informationcollectionsystem.entity.DTO.DataReportFormDTO", "公司报表数据");
    }

    public static String getColumnChineseName(String column){
        Field[] fields = ColumnNameCN.class.getFields();
        for(var field : fields){
            HashMap<String, String> v;
            try {
                v = (HashMap<String, String>)field.get(null);
            } catch (IllegalAccessException e) {throw new RuntimeException(e);}
            var result = v.get(LowerCamelToLowerUnderscore.exec(column));
            if (result != null)
                return result;
        }
        return null;
    }
}
